package com.duleme.service.impl;

import com.duleme.dao.AdminDao;
import com.duleme.entity.Admin;
import com.duleme.service.AdminService;

import java.util.Date;
import java.util.List;

public class AdminServiceImpl implements AdminService {
    AdminDao adminDao = new AdminDao();

    @Override
    public List<Admin> getAllAadmin() {

        return adminDao.getAdminAll();
    }

    @Override
    public Admin login(int userID, String password) {
        if (userID>=10000&&password!=null){
            return adminDao.findAdminByID(userID,password);
        }else {
            return null;
        }
    }

    @Override
    public Boolean register(String userName, String password) {
        if (userName !=null && password != null){
            Admin admin = new Admin();
            admin.setAdminName(userName);
            admin.setAdminPwd(password);
            admin.setCreateTime(new Date());
            return adminDao.insertAdmin(admin);
        }
        return  false;

    }

    @Override
    public Boolean delete(int userID) {
        if (userID < 10000){
            return false;
        }else {
            Integer[] ids = {userID};
            return adminDao.delete(ids);
        }
    }
}
